package classpath

import "os"
import "strings"

const pathListSeparator = string(os.PathListSeparator)

type Entry interface {
    //寻找和加载class文件
    readClass(className string) ([]byte, Entry, error)

    //相当于Java中的toString()
    String() string
}

//根据参数创建不同类型的Entry
func newEntry(path string) Entry {
    if strings.Contains(path, pathListSeparator) {
        return newCompositeEntry(path)
    }

    if strings.HasSuffix(path, "*") {
        return newWildcardEntry(path)
    }

    if strings.HasSuffix(path, ".jar") || strings.HasSuffix(path, ".JAR") ||
        strings.HasSuffix(path, ".zip") || strings.HasSuffix(path, ".ZIP") {

        return newZipEntry(path)
    }

    //目录形式的类路径
    return newDirEntry(path)
}